package com.gs.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gs.action.datamodel.CaseDataModel;
import com.gs.bean.Case;
import com.liang.ext.bean.ExtFormBean;
import com.liang.log.Log;

@SuppressWarnings("serial")
@Scope(value="prototype")
@Controller(value="caseAction")
public class CaseAction extends UploadAction {

	private CaseDataModel dataModel;
	
	public String load() throws Exception{
		
		return null;
	}
	
	public String save() throws Exception{
		String path = "res/images/case";
		Case caze = dataModel.getCaze();
		
		setSavePath(path);
		Log.info("save");
		upload();
		caze.setLogo(path+"/"+getFileName().get(0));
		Log.info("caze:"+caze.getLogo());
		ExtFormBean bean = new ExtFormBean();
		bean.setMsg("新增成功");
		bean.setSuccess(true);
		bean.setResult(caze);
		writeExtFormBean(bean);
		return null;
	}

	public CaseDataModel getDataModel() {
		return dataModel;
	}

	public void setDataModel(CaseDataModel dataModel) {
		this.dataModel = dataModel;
	}
}
